import random
from bs4 import BeautifulSoup

import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
}
# 模拟浏览器
headers["X-Forwarded-For"] = "%s.%s.%s.%s" % (
    random.randrange(1, 200, 20), random.randrange(1, 200, 20), random.randrange(1, 200, 20),
    random.randrange(1, 200, 20))  # IP地址构造

url = 'https://price.pcauto.com.cn/top/sales/s1-t1.html'

page_text = requests.get(url=url, headers=headers).text

soup = BeautifulSoup(page_text, "lxml")

tr_list = soup.select(".level-table")[0].find_all("tr")

resultList = []
for item in tr_list:
    resultList.append(item.text.split("\n")[1:-2])

print(resultList)
